//
//  SearchHistoryController.m
//  ManageMoney
//
//  Created by epwk on 15/10/14.
//  Copyright © 2015年 db. All rights reserved.
//

#import "SearchHistoryController.h"

#import "PayHistoryViewController.h"

@interface SearchHistoryController ()

@property (weak, nonatomic) IBOutlet UILabel *startDateLab;//开始时间
@property (weak, nonatomic) IBOutlet UILabel *endDateLab;//结束时间
@property (weak, nonatomic) IBOutlet UIButton *chageMoneyBtn;//查询 充值
@property (weak, nonatomic) IBOutlet UIButton *takeOffMoneyBtn;// 查询 提现

@end

@implementation SearchHistoryController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"账户查询";
    NSString *dateStr = [NSString getCurrentDate];
    _startDateLab.text = dateStr;
    _endDateLab.text = dateStr;
    
    _chageMoneyBtn.layer.cornerRadius = 3;
    _takeOffMoneyBtn.layer.cornerRadius =3;
}
- (IBAction)historyLookAction:(id)sender {
    UIButton *btn = (UIButton *)sender;
    switch (btn.tag) {
        case 0://查询 充值记录
        {
            PayHistoryViewController *ctr = [[PayHistoryViewController alloc] initWithNibName:@"PayHistoryViewController" bundle:nil];
            ctr.chargeBool = YES;
            ctr.payChannelDic = _payChannelDic;
            ctr.startDate = _startDateLab.text;
            ctr.endDate = _endDateLab.text;
            [self.navigationController pushViewController:ctr animated:YES];
        }
            break;
        case 1://查询 提现记录
        {
            PayHistoryViewController *ctr = [[PayHistoryViewController alloc] initWithNibName:@"PayHistoryViewController" bundle:nil];
            ctr.chargeBool = NO;
            ctr.payChannelDic = _payChannelDic;
            ctr.startDate = _startDateLab.text;
            ctr.endDate = _endDateLab.text;
            [self.navigationController pushViewController:ctr animated:YES];
        }
            break;
        default:
            break;
    }
}

- (IBAction)datePicker:(id)sender {
    UIButton *btn = (UIButton *)sender;
    
    [_pickview remove];
    NSDate *date=[NSDate dateWithTimeIntervalSinceNow:0];
    _pickview=[[ZHPickView alloc] initDatePickWithDate:date datePickerMode:UIDatePickerModeDate isHaveNavControler:NO inView:self.view];
    _pickview.tag = btn.tag;
    _pickview.delegate=self;
    [_pickview show];
    
}
#pragma mark ZhpickVIewDelegate

-(void)toobarDonBtnHaveClick:(ZHPickView *)pickView resultString:(NSString *)resultString{
    switch (pickView.tag) {
        case 0:
            _startDateLab.text = [resultString substringToIndex:10];
            break;
        case 1:
            _endDateLab.text = [resultString substringToIndex:10];
            break;
            
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
